home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…eptember: Technology Seed / September 98 ADC Seed CD.toast / FireWire 1.1 DR2 SDK / Source / FWiX / FWiXApp / FWiXmain.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-15  |  10.1 KB  |  393 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        FWXmain.h
  3.  
  4.     Contains:    Definitions for FireWire File Exchange application.
  5.  
  6.     Version:    1.0
  7.  
  8.     Written by:    Jay Lloyd
  9.  
  10.     Copyright:    © 1996-1997 by Apple Computer, Inc., all rights reserved.
  11.  
  12.     File Ownership:
  13.  
  14.         DRI:                Jay Lloyd
  15.  
  16.         Other Contact:        
  17.  
  18.         Technology:            FireWire
  19.  
  20.     Writers:
  21.  
  22.         (jkl)    Jay Lloyd
  23.  
  24.     Change History (most recent first):
  25.  
  26.       <FW23>     6/19/97    jkl        Added another preference flag for icon view. Made preferences a
  27.                                     long instead of a byte. Added AppleScript defines and an
  28.                                     AppleEvent send queue definition.
  29.       <FW22>     6/10/97    jkl        Moved QDGlobals to main.c global for easier code warrior
  30.                                     compiles.
  31.       <FW21>     5/27/97    jkl        Added room for 4 byte packet index to control packet buffers.
  32.       <FW20>     5/15/97    jkl        Added routine declarations.
  33.       <FW19>      5/7/97    jkl        Updated list data structures with a previous pointer to make
  34.                                     them double linked lists.
  35.       <FW18>     4/29/97    jkl        Added declarations for some new routines and added a busyAlert
  36.                                     resource ID.
  37.       <FW17>      4/8/97    jkl        Added key definitions for page up, page down, home and end for
  38.                                     keyboard scrolling. Changed my initials.
  39.       <FW16>     3/18/97    jkl        Moved prefs related definitions to prefs.h.
  40.       <FW15>     2/27/97    jkl        Modified constants for file conflict preferences to be under
  41.                                     receiver control. Added constants for scrolling support in
  42.                                     sender window.
  43.       <FW14>     2/21/97    jkl        Got rid of unused constants and added memory error alert.
  44.       <FW13>     2/19/97    jkl        Adjusted counts and sizes of buffers.
  45.       <FW12>     2/13/97    jkl        Modified count and size of buffers.
  46.       <FW11>     2/13/97    jkl        Modified count and size of buffers.
  47.       <FW10>     2/11/97    jkl        Added queue definitions, modified buffer numbers and sizes.
  48.        <FW9>      2/2/97    jkl        Modified resource definitions to match HI spec.
  49.        <FW8>     1/27/97    ES        Added defs for FW Control PB queue.
  50.        <FW7>     1/27/97    jkl        Added error alert resource id's and error constants. Updated
  51.                                     menu constants. Added a sendflags field to the send queue.
  52.                                     Defined a pre-send check queue record and my timer task record
  53.                                     with node id on the end.
  54.        <FW6>     1/16/97    jkl        Changed notify sound resource preference to not conflict with
  55.                                     another string resource.
  56.        <FW5>     1/16/97    jkl        Added new user interface features. Constants for notification
  57.                                     and preferences dialog.
  58.        <FW4>    11/13/96    jkl        Added data structure to handle receives from multiple machines.
  59.        <FW3>     10/16/96    jkl        Modified queue structure for send queue to handle
  60.                                     multiple files and folders.
  61.        <FW2>     10/16/96    jkl        renamed constants for clarity, changed number
  62.                                        and sizes of buffers for performance experiments
  63.        <FW1>     10/2/96    jkl        initial check-in
  64. */
  65.  
  66. #ifndef __FWXMAIN__
  67. #define __FWXMAIN__
  68.  
  69. #include <Drag.h>
  70. #include <Timer.h>
  71.  
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif
  75.  
  76. #if PRAGMA_IMPORT_SUPPORTED
  77. #pragma import on
  78. #endif
  79.  
  80. #if PRAGMA_ALIGN_SUPPORTED
  81. #pragma options align=mac68k
  82. #endif
  83.  
  84. #define kDITop            0x0050
  85. #define kDILeft            0x0070
  86.  
  87. #define    kFileReadBufs        2                // number of buffers to allocate for file reads
  88. #define kFileReadBufSize    (32*1024)        // buffer size for file reads
  89.  
  90. #define kFWControlParams    20                // number of param blocks to allocate for control packets
  91. #define kFWControlParamBufferSize    (sizeof (CInfoPBRec) + 8)        // size of control packet buffer, big enough for CatInfo
  92.  
  93. #define kFWReadControlBufs    20                // number of read control buffers to pass to driver
  94. #define kFWReadControlBufSize        (sizeof (CInfoPBRec) + 8)        // size of read control buffers
  95.  
  96. #define kFWReadDataBufs        6                // number of read data buffers to pass to driver
  97. #define kFWReadDataBufSize    (32*1024)        // size of read data buffers
  98.  
  99. #define    kCanSelectDesktop    true
  100.  
  101. // error constants
  102. enum
  103. {
  104.     kItemExistsError        = 1,
  105.     kSpaceError                = 2,
  106.     kUnknownError            = -1
  107. };
  108.  
  109. enum
  110. {
  111.     // Apple event class for FireWire File Exchange driver family.
  112.     kAEFWXSendEventID    = 'send',
  113.     kAEFWXNodeListID    = 'node',
  114.     kAEFWXNodeKeyword    = 'node'
  115. };
  116.  
  117. // prefs constants
  118. enum
  119. {
  120.     kNoNotificationPosted    = 0,
  121.     kNotificationPosted        = 1,
  122.     
  123.     // the preferences are stored as a long with these bit fields
  124.     kConflictCancel            = 0x01,
  125.     kConflictRename            = 0x02,
  126.     kConflictOverwrite        = 0x04,
  127.     kNotifyFlash            = 0x10,
  128.     kNotifyAlert            = 0x20,
  129.     kNotifySound            = 0x40,
  130.     kNotifyOpen                = 0x80,
  131.     kIconView                = 0x100            // if bit is clear: large icon, set: small icon
  132. };
  133.  
  134. // resource and menu constants
  135. enum
  136. {
  137.     kMenuBarResourceID        = 128,
  138.     kWindowResourceID        = 128,
  139.         
  140.     kAboutAlertResourceID    = 128,
  141.     kNoNameAlertID            = 130,
  142.     kUnknownErrAlertID        = 133,
  143.     kSpaceErrAlertID        = 134,
  144.     kCantQuitAlertID        = 136,
  145.     kCommunicationErrorAlertID    = 137,
  146.     kNodeDisconnectAlertID    = 138,
  147.     kMemoryErrorAlertID        = 139,
  148.     kIOErrorAlertID            = 140,
  149.     kRecvErrorAlertID        = 141,
  150.     kItemExistsErrAlertID    = 142,
  151.     kItemBusyErrAlertID        = 143,
  152.     kNSVErrAlertID            = 144,
  153.     kReceiveAlertID            = 145,
  154.     kReceiverQuitAlertID    = 146,
  155.  
  156.     kAppleMenuID             = 128,
  157.     kAboutMenuItem             = 1,
  158.     
  159.     kFileMenuID                = 129,
  160.     kOpenMenuItem            = 1,
  161.     kCloseMenuItem            = 2,
  162.     kOpenDropMenuItem        = 4,
  163.     kQuitMenuItem            = 6,
  164.  
  165.     kEditMenuID                = 130,
  166.     kPrefsMenuItem            = 8,
  167.  
  168.     kViewMenuID                = 131,
  169.     kSmallIconMenuItem        = 1,
  170.     kIconMenuItem            = 2,
  171.     
  172.     kPrefsDlogID            = 131,
  173.     kOKButton                = 1,
  174.     kCancelButton            = 2,
  175.     kFlashBox                = 3,
  176.     kAlertBox                = 4,
  177.     kSoundBox                = 5,
  178.     kOpenBox                = 6,
  179.     kSoundPopup                = 7,
  180.     kDropName                = 9,
  181.     kDropButton                = 10,
  182.     kCancelRadio            = 12,
  183.     kRenameRadio            = 13,
  184.     kOverwriteRadio            = 14,
  185.     kDefaultUserItem        = 16,
  186.     
  187.     kReturnKey                = 13,
  188.     kEnterKey                = 3,
  189.     kEscapeKey                = 27,
  190.     kPeriodKey                = 46,
  191.     kPageUpKey                = 11,
  192.     kPageDownKey            = 12,
  193.     kHomeKey                = 1,
  194.     kEndKey                    = 4,
  195.  
  196.     kProgressPrompt            = 2,
  197.     kProgressBarUserItem    = 4,
  198.     kCopyProgressDlog        = 129,
  199.     
  200.     kVScrollBar                = 128,    
  201.     kHScrollBar                = 129,
  202.     
  203.     kDropIconSuiteID        = 128,
  204.     kAppIconSuiteID            = 129,
  205.     kNotifyIcon                = 128,
  206.     kNotifyString            = 128,
  207.     kNetworkNameID            = -16413
  208. };
  209.  
  210. // scroll bar offset constants
  211. enum
  212. {
  213.     kScrollBarWidth            = 16,
  214.     kScrollBarAdjust        = kScrollBarWidth - 1,
  215.     kScrollBarTweek            = 2
  216. };
  217.  
  218. // global data for Drag Manager handlers
  219. struct DragHandlerGlobals {
  220.     Boolean        acceptableDragFlag;
  221.     short        hilitedSpace;
  222. };
  223. typedef struct DragHandlerGlobals DragHandlerGlobals, *DragHandlerGlobalsPtr;
  224.  
  225.  
  226. // global data for application
  227. struct FWXAppStruct
  228. {
  229.     DragHandlerGlobals            dragHandlerGlobals;
  230.     
  231.     AEEventHandlerUPP            openApplicationEventHandler;
  232.     AEEventHandlerUPP            openDocumentsEventHandler;
  233.     AEEventHandlerUPP            quitApplicationEventHandler;
  234.     AEEventHandlerUPP            fileSpecListHandler;
  235.     AEEventHandlerUPP            sendItemsEventHandler;
  236.     AEEventHandlerUPP            getNodeListEventHandler;
  237.     DragTrackingHandlerUPP        dragTrackingHandler;
  238.     DragReceiveHandlerUPP        dragReceiveHandler;
  239.     DragReceiveHandlerUPP        deviceAddedEventHandler;
  240.     DragReceiveHandlerUPP        deviceRemovedEventHandler;
  241.     IOCompletionUPP                fileWriteCompletionHandler;
  242.     IOCompletionUPP                fileReadCompletionHandler;
  243.     
  244.     FWXClientID                    fwxClientID;
  245.  
  246.     WindowPtr                    pSenderWindow;
  247.     
  248.     NMRecPtr                    pNotifyRec;
  249.     
  250.     FSSpec                        fwixReceiveFolder;
  251.     Str31                        fwixNotifySound;
  252.     UInt32                        fwixPrefs;
  253.     
  254.     Boolean                        getNodeListEventHandlerInstalled;
  255.     Boolean                        sendItemsEventHandlerInstalled;
  256.     Boolean                        deviceRemovedEventHandlerInstalled;
  257.     Boolean                        deviceAddedEventHandlerInstalled;
  258.     Boolean                        dragReceiveHandlerInstalled;
  259.     Boolean                        dragTrackingHandlerInstalled;
  260.     Boolean                        fileSpecListHandlerInstalled;
  261.     Boolean                        quitApplicationEventHandlerInstalled;
  262.     Boolean                        openDocumentsEventHandlerInstalled;
  263.     Boolean                        openApplicationEventHandlerInstalled;
  264.     Boolean                        quitFlag;    
  265.     Boolean                        inForeground;
  266. };
  267. typedef struct FWXAppStruct        FWXAppData,
  268.                                 *FWXAppDataPtr;
  269.  
  270.  
  271. typedef struct FWXPacketStruct FWXPacket, *FWXPacketPtr;
  272. struct FWXPacketStruct
  273. {
  274.     UInt32                    packetIndex;
  275.     UInt32                    packetType;
  276.     Ptr                        packetData;
  277. };
  278.  
  279.  
  280. typedef struct TxFsSpecQueueStruct TxFSSpec, *TxFSSpecPtr;
  281. struct TxFsSpecQueueStruct
  282. {
  283.     QElemPtr                qLink;
  284.     FSSpecPtr                pFSSpec;
  285.     FWXNodeID                recvNode;
  286.     UInt32                    itemType;
  287. };
  288.  
  289. typedef struct AESendQueueStruct AESendRec, *AESendRecPtr;
  290. struct AESendQueueStruct
  291. {
  292.     QElemPtr                qLink;
  293.     FSSpecPtr                pSendItemsList;
  294.     FWXNodeID                recvNode;
  295.     UInt16                    numSendItems;
  296. };
  297.  
  298. typedef struct NodeSendStruct NodeSendItem, *NodeSendItemPtr;
  299. struct NodeSendStruct
  300. {
  301.     NodeSendItemPtr            pNextSendItem,
  302.                             pPreviousSendItem;
  303.     FSSpec                    sendItemSpec;
  304.     UInt32                    itemSize;
  305. };
  306.  
  307. typedef struct MyTMTask MyTMTask, *MyTMTaskPtr;
  308. struct MyTMTask
  309. {
  310.     TMTask            timerTask;                // regular time struct
  311.     FWXNodeID        nodeID;                    // add node id since we will normally
  312.                                             // be using this for errors with nodes
  313. };
  314.  
  315. typedef struct CurFileQueueStruct CurFileInfo, *CurFileInfoPtr;
  316. struct CurFileQueueStruct
  317. {
  318.     QElemPtr                qLink;
  319.     FSSpecPtr                pCurFileSpec;
  320.     FWXClientID                curFileSenderID;
  321.     UInt32                    forkLength;
  322.     UInt32                    recvLength;
  323.     SInt32                    curDirID;
  324.     SInt16                    curFileRefNum;
  325.     OSErr                    curError;
  326. };
  327.  
  328. OSErr HandlePrefsDialog (void);
  329. OSErr InitPrefs (void);
  330. void HandleIdle (void);
  331. OSErr GetCurFileInfo(
  332.     FWXNodeID                recvNodeID,
  333.     CurFileInfoPtr            *hCurFileInfo,
  334.     Boolean                    createNew);
  335. OSErr InitRecvFolder(
  336.     SInt32                    *dirID);
  337. void UpdateNotification (
  338.     NMRecPtr                pNMRec);
  339. OSErr SaveWindowPos (
  340.     WindowPtr                pWin);
  341. OSErr GetWindowPos (
  342.     Rect                    *r);
  343. void HandleUpdateEvent (
  344.     EventRecord                *pEventRecord);
  345. SInt16 HandleCautionAlert (
  346.     SInt16                    alertResID);
  347. SInt16 HandleStopAlert (
  348.     SInt16                    alertResID);
  349. SInt16 HandleNoteAlert (
  350.     SInt16                    alertResID);
  351. SInt16 HandleAlert (
  352.     SInt16                    alertResID);
  353. pascal OSErr HandleFileWriteComplete (
  354.     ParmBlkPtr                pFilePB);
  355. void HandleFWWriteComplete (
  356.     IOParamPtr                pFilePB);    
  357. void HandleFWControlComplete (
  358.     IOParamPtr                pFWPB);
  359. void HandleFWReadComplete (
  360.     IOParamPtr                pFilePB);
  361. pascal OSErr HandleFileReadComplete (
  362.     ParmBlkPtr                pFilePB);
  363. void SetupFileReadPB (
  364.     IOParamPtr                pb);
  365. void SetupFWWritePB(
  366.     IOParamPtr                pb);
  367. void SetupFWControlPB (
  368.     IOParamPtr                pb);
  369. OSErr FWIXDequeue (
  370.     QElemPtr                *ppQElem,
  371.     QHdrPtr                    pQHdr);
  372. OSErr UpdatePrefsFile (void);
  373. OSErr SendFSSpecListToSelf (
  374.     FWXNodeID                fwxNodeID,
  375.     FSSpecPtr                pFSSpecList,
  376.     UInt16                    numItems);
  377.  
  378.  
  379.  
  380. #if PRAGMA_ALIGN_SUPPORTED
  381. #pragma options align=reset
  382. #endif
  383.  
  384. #if PRAGMA_IMPORT_SUPPORTED
  385. #pragma import off
  386. #endif
  387.  
  388. #ifdef __cplusplus
  389. }
  390. #endif
  391.  
  392. #endif
  393.